import path from 'path'
import { defineConfig } from 'vite'
import { getBuild, getPlugins } from './build/config'
import { globalVar } from './build/env/globalVar'
import { viteVar } from 'vite-var'

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
    const env = globalVar(command, mode)

    return {
        base: './',
        resolve: {
            alias: {
                '~/': `${path.resolve(__dirname, 'src')}/`
            }
        },
        css: { postcss: { plugins: [viteVar(env as any)] } },
        plugins: getPlugins(env),
        build: getBuild(env),
        server: {
            host: '0.0.0.0',
            port: 6520,
            open: false,
        },
    }
})
